<route lang="json5">
{
  style: {
    navigationBarTitleText: '动态列表',
    enablePullDownRefresh: true,
  },
}
</route>
<template>
  <div class="list">
    <LoadPage ref="loadPage" url="/posts-info-app/open/page" :immediate="false">
      <template #default="{ list }">
        <div class="active-list" v-if="list.length > 0">
          <Tend v-for="(item, index) in list" class="mt-10px" :data="item" :key="index" />
        </div>
      </template>
    </LoadPage>
  </div>
</template>

<script lang="ts" setup>
import Tend from '@/pages-sub/g-components/Trend/index.vue'

const loadPage = ref()

let id = null
onLoad((query) => {
  if (query.id) {
    id = query.id
    getData(true)
  }
})

// 上拉加载
onReachBottom(() => {
  getData(false)
})
// 下拉刷新
onPullDownRefresh(() => {
  getData(true)
})

function getData(isRa = false) {
  if (loadPage.value) {
    loadPage.value?.getData(
      {
        createUser: id,
      },
      isRa,
    )
  } else {
    setTimeout(() => {
      getData(isRa)
    }, 300)
  }
}
</script>

<style scoped lang="scss">
.list {
  min-height: 100vh;
  padding: 28rpx 30rpx;
  background-color: var(--bgc4);
}
</style>
